import { legacy_createStore } from 'redux'

const initialState = {
  counter: 0
}
export type IState = Readonly<typeof initialState>

function reducer(state: IState = initialState, action: any): IState {
  switch (action.type) {
    case 'INCREMENT':
      return { counter: state.counter + 1 }
    case 'DECREMENT':
      return { counter: state.counter - 1 }
    default:
      return state
  }
}

const store = legacy_createStore(reducer)

export default store
